#pragma once
#include "../SGD Wrappers/SGD_String.h"
#include "../SGD Wrappers/SGD_Geometry.h"
#include "Flyweight.h"
#include "Particle.h"
#include <vector>

enum Shape{POINT_EMITTER, LINE_EMITTER, RECT_EMITTER, CIRCLE_EMITTER};

class Emitter
{
public:

	Emitter() { m_pFlyweight = nullptr; };
	Emitter(Flyweight fw, float Max);
	~Emitter();

	void Update(float dt);
	void Render();

	Particle CreateParticle();
	void ResetParticle(Particle& p);
	void DeleteFlyweight();

	//Accessors
	std::string		GetImageID()		{ return m_szImageID; }
	int				GetMaxParticles()	{ return m_nMaxParticles; }
	float			GetSpawnRate()		{ return m_fSpawnRate; }
	SGD::Vector		GetVelocity()		{ return m_v2fVelocity; }
	SGD::Point		GetPosition()		{ return m_ptPosition; }
	bool			GetLooping()		{ return m_bLooping; }
	Flyweight*		GetFlyweight()		{ return m_pFlyweight; }
	int				GetWidth()			{ return m_nWidth; }
	int				GetHeight()			{ return m_nHight; }
	int				GetShape()			{ return m_nShape; }
	int				GetRadius()			{ return m_nRadius; }
	std::vector<Particle> GetAliveVec()	{ return m_AliveVec; }

	//Mutators
	void		SetImageID(const char * str);
	void		SetMaxParticles(int max)		{ m_nMaxParticles = max; }
	void		SetSpawnRate(float spawn)		{ m_fSpawnRate = spawn; }
	void		SetVelocity(SGD::Vector vel)	{ m_v2fVelocity = vel; }
	void		SetPosition(SGD::Point pos)		{ m_ptPosition = pos; }
	void		SetLooping(bool loop)			{ m_bLooping = loop; }
	void		SetFlyweight(Flyweight fw);
	void		SetWidth(int width)				{ m_nWidth = width; }
	void		SetHeight(int height)			{ m_nHight = height; }
	void		SetOwner(BaseObject* owner)		{ m_pOwner = owner; }
	void		SetShape(int n)					{ m_nShape = n; }
	void		SetRadius(int n)				{ m_nRadius = n; }
	void		SetOffsetX(int n)				{ m_nOffsetX = n; }
	void		SetOffsetY(int n)				{ m_nOffsetY = n; }
	void		SetHasLooped(bool b)			{ m_bHasLooped = b; }
private:

	BaseObject*				m_pOwner;
	std::string				m_szImageID;
	int						m_nMaxParticles;
	float					m_fSpawnRate;
	float					m_fSpawnTimer;
	SGD::Vector				m_v2fVelocity;
	SGD::Point				m_ptPosition;
	bool					m_bLooping;
	bool					m_bHasLooped = false;
	Flyweight*				m_pFlyweight;
	int						m_nWidth;
	int						m_nHight;
	int						m_nRadius;
	std::vector<Particle>	m_AliveVec;
	SGD::Vector				m_vecPartVelocities;
	int						m_nShape;
	int						m_nOffsetX;
	int						m_nOffsetY;

};